package com.ruoyi.system.waishu;

import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.Map;

/**
 * 业务调用外数实体类
 */
public class InvokeServiceImpl implements InvokeService, ApplicationContextAware {

    private static ApplicationContext context;

    private ApiServiceFactory apiServiceFactory;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        context = applicationContext;
    }
    @Override
    public JSONObject invoke(AbstractRequest request, Map<String, String> params, String ServiceId) {
        ApiReq apiReq = new ApiReq();
        apiReq.setApiCode(ServiceId);
        return apiServiceFactory.builder(apiReq.getApiCode()).call(apiReq);
    }


}
